{% extends 'layout.html' %}
{% load static %}
{% load permission %}

{% block content %}

    <div style="margin-bottom: 5px; text-decoration: none">
        <a class="btn btn-success" href="{% url 'level_add' %}"><span class="glyphicon glyphicon-plus-sign"></span> 新建</a>
    </div>

<!--    {% add_permission request 'level_add' %}-->
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>ID</th>
                <th>标题</th>
                <th>折扣</th>
                {% if request|has_permission:"level_edit, level_delete" %}
                    <th>操作</th>
                {% endif %}
            </tr>
        </thead>
        <tbody>
        {% for row in queryset %}
            <tr>
                <td>{{ row.id }}</td>
                <td>{{ row.title }}</td>
                <td>{{ row.percent }}%</td>
                {% if request|has_permission:"level_edit,level_delete" %}
                <td>
<!--                    <a href="{% url 'level_edit' pk=row.id %}" class="btn btn-primary btn-xs">编辑</a>-->
<!--                    <a href="{% url 'level_delete' pk=row.id %}" class="btn btn-danger btn-xs">删除</a>-->
                    {% edit_permission request 'level_edit' pk=row.id %}
                    {% delete_url_permission request 'level_delete' pk=row.id %}
                </td>
                {% endif %}
            </tr>
        {% endfor %}
      </tbody>
    </table>
{% endblock %}